import 'package:flutter/material.dart';
import 'package:flutter_app/components/layout.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool showPsw = false;

  void setShowPsw() {
    setState(() {
      showPsw = !showPsw;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        iconTheme: IconThemeData(
          color: Colors.black, //修改颜色
        ),
        backgroundColor: Colors.transparent,
        elevation: 0,
        actions: [
          TextButton(
              onPressed: () {
                Navigator.pushNamed(context, '/reg');
              },
              child: Text('注册'))
        ],
      ),
      body: Container(
        padding: EdgeInsets.symmetric(horizontal: 20.0),
        child: ColumnStart(
          children: [
            SizedBox(
              height: 40,
            ),
            Text('请使用手机号或邮箱登录',
                style: TextStyle(fontSize: 17, color: Colors.black)),
            SizedBox(
              height: 40,
            ),
            TextField(
                decoration: InputDecoration(
                    hintText: '邮箱或手机号',
                    hintStyle: TextStyle(color: Colors.grey),
                    contentPadding: const EdgeInsets.symmetric(vertical: 0.0))
            ),
            SizedBox(
              height: 40,
            ),
            TextField(
                obscureText: !showPsw,
                decoration: InputDecoration(
                    hintText: '请输入登录密码',
                    hintStyle: TextStyle(color: Colors.grey,height: 2.5),
                    contentPadding: const EdgeInsets.symmetric(vertical: 0.0),
                    suffixIcon: IconButton(
                        onPressed: setShowPsw,
                        icon: ImageIcon(AssetImage(showPsw ? "assets/images/ic_eye_open.png":"assets/images/ic_eye_close.png"))
                    )
                )
            ),
            SizedBox(
              height: 70,
            ),
            Container(
              height: 45,
              width: MediaQuery.of(context).size.width,
              child: FlatButton(
                  color: Colors.blueAccent,
                  textColor: Colors.white,
                  onPressed: () {},
                  child: Text('下一步')),
            ),
            Container(
                alignment: Alignment.centerRight,
                child: TextButton(
                    onPressed: () {
                      Navigator.pushNamed(context, '/forget');
                    },
                    child: Text('忘记密码')))
          ],
        ),
      ),
    );
  }
}
